<template>
	<view>
		<view class="uni-common-mt">
			<!-- <form @submit="formSubmit"></form> -->
			<view class="uni-form-item uni-column">
				<view class="title">用户名</view>
				<input class="uni-input" v-model="account" focus placeholder="请输入用户名" />
			</view>
			<view class="uni-form-item uni-column">
				<view class="title">密码</view>
				<input class="uni-input" v-model="password" password type="text" placeholder="请输入密码" />
			</view>
			<button type="primary" :loading="loginLoading" @click="login">登 录</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loginLoading: false,
				account: "",
				password: ""
			}
		},
		methods: {
			login () {
				this.loginLoading = true
				this.$api.login(this.account, this.password).then(
					(res) => {
						console.log("s",res)
						this.$api.setToken(res.result.token)
					}
				).catch(
					(res) => {
						console.log("r",res)
					}
				).finally(() => {
					console.log("complete")
					this.loginLoading = false
				})
				// uni.navigateTo({
				// 	url:"../index/index",
				// 	success() {
				// 		console.log("success")
				// 	},
				// 	fail() {
				// 		console.log("fail")
				// 	},
				// 	complete() {
				// 		console.log("complete")
				// 	}
				// })
			}
		}
	}
</script>

<style lang="scss">

</style>
